package com.gzs.support.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.gzs.support.cache.redis.RedisCache;
import com.gzs.support.cache.redis.RedisCacheProvider;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/**/applicationContext.xml")
public class Values {
    @Autowired
	private RedisCacheProvider<String, String> redisCacheProvider;
	@Test
	public void test() {
	  RedisCache<String, String> cache = redisCacheProvider.getCache("testcache");
	  cache.opsForValue().set("testkkk", "mammamammamq");
	 
	  assertTrue("mammamammamq".equals(cache.opsForValue().get("testkkk")));
	}
	
	@Test
	public void testList() {
	  RedisCache<String, String> cache = redisCacheProvider.getCache("testcachelist");
	  String key="123123";
	  cache.remove(key);
	  System.out.println(cache.opsForList().size(key));
	  
	 
	  cache.opsForList().leftPush(key, "中文");
	  assertEquals("中文", cache.opsForList().leftPop(key));
	  cache.opsForList().leftPush(key, "中文的值撒");
	  assertTrue(1==  cache.opsForList().size(key));
	  cache.remove(key);
	  assertTrue(0==  cache.opsForList().size(key));
	 
	 
	 
	}
}
